server {
    server_name admin.<%= domain %>;
    rewrite ^(.*) http://<%= domain %>/admin permanent;
}

server {

    server_name portal.<%= domain %>;
    rewrite ^(.*) http://<%= domain %>/portal permanent;
}

server {
    server_name *.<%= domain %>;
    rewrite ^(.*) http://<%= domain %>$1 permanent;
}